import FileToolsBar from "../../components/FileToolsBar/FileToolsBar";
import CloudDownloadIcon from '@mui/icons-material/CloudDownload';
import downloadFiles from '../../utils/FileDownload';

const apiUrl = process.env.REACT_APP_API_URL;
const debugMode = process.env.REACT_APP_DEBUG_MODE === 'true';
function ShareToolBar(props) {
    let selectedFiles = props.selectedFiles;
    let onDone = props.onDone;
    function handleDownLoad(e) {
        console.log(selectedFiles)
        let fileName = 'downloadFile'
        if (selectedFiles.length === 1) {
            fileName = selectedFiles[0].fileName
        } else {
            fileName = 'downloadFiles.zip'
        }
        downloadFiles(selectedFiles.map((sele)=> sele.id), fileName)
    }
    const toolbar = [
        {name: '下载', params: {startIcon: <CloudDownloadIcon/>, variant:"contained", onClick:handleDownLoad}},
    ];
    return (<FileToolsBar toolbar={toolbar} {...props} />)
}


export default ShareToolBar;